package com.fanshuai2.niuke.strings;

import java.util.*;

public class IpCheck {
    static String valid(String ip) {
        String[] arr = ip.split("\\.");
        if (arr.length != 4) {
            return "NO";
        }

        String valid = "YES";
        for (int i = 0; i < 4; i++) {
            if (arr[i].length() == 0 || arr[i].length() > 3) {
                valid = "NO";
                break;
            }
            for (int j = 0; j < arr[i].length(); j++) {
                char ch = arr[i].charAt(j);
                if (ch < '0' || ch > '9') {
                    valid = "NO";
                    break;
                }
            }
            if (arr[i].length() >= 2 && arr[i].startsWith("0")) {
                valid = "NO";
                break;
            }
            int n = Integer.parseInt(arr[i]);
            if (n < 0 || n > 255) {
                valid = "NO";
                break;
            }
        }
        return valid;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextLine()) {
            String ip = in.nextLine();
            System.out.println(valid(ip));
        }
    }
}
